import { Component } from 'react';
import { ContContext } from '../context/contContext';
import './theme/css/nameCtrl.scss';

class nameCtrl extends Component {
    // eslint-disable-next-line
    static contextType=ContContext;
    constructor(props) {
        super(props);
        this.inputChange = this.inputChange.bind(this);
    }

    inputChange(val) {
        this.context.infChange({ age: val.target.value });
    }

    render() {
        return (
            <div className="name-box">
                <span>姓名：{this.context.obj.name}</span>
                <div>
                    修改年龄<input onInput={this.inputChange}></input>
                </div>
            </div>
        );
    }
}
export default nameCtrl;
